package edu.uestc.canary.entity.dto;

/**
 * 统一响应数据模型
 * @param status 业务状态码
 * @param data 响应数据
 * @param message 业务消息
 * @param <T> 类型化参数
 */
public record Result<T>(int status, T data, String message) {
    public static Result ok(){
        return new Result(2000, null, "业务执行成功");
    }

    public static<T> Result ok(T data){
        return new Result(2000, data, "业务执行成功");
    }

    public static<T> Result ok(T data, String message){
        return new Result(2000, data, message);
    }

    public static Result fail(){
        return new Result(5000, null, "业务执行失败");
    }

    public static<T> Result fail(T data){
        return new Result(5000, data, "业务执行失败");
    }

    public static<T> Result fail(T data, String message){
        return new Result(5000, data, message);
    }

}
